﻿
@{
    ViewData["Title"] = "AddIndex";
    Layout = "~/Views/Share/_Layoutiframe.cshtml";
}


<div style="margin-right:30px;padding-top:10px;">
    <form id="form1" class="layui-form">
        <div style="position:absolute; padding-right:10px;">
            <table class="form">
                <tr>
                    <th class="formTitle">仓库名称</th>
                    <td class="formValue">
                        <input id="StoreName" name="StoreName" type="text" class="form-control input-sm" autocomplete="off"  />
                    </td>                 
                </tr>

                <tr>
                    <th class="formTitle">地址</th>
                    <td class="formValue" >
                        <input id="Address" name="Address" type="text" class="form-control input-sm" autocomplete="off" />
                    </td>

                </tr>
                <tr>
                    <th class="formTitle">面积</th>
                    <td class="formValue">
                        <input id="Sizes" name="Sizes" type="text" class="form-control input-sm" autocomplete="off" />
                    </td>
                   
                </tr>

                <tr>
                    <th class="formTitle">用途描述</th>
                    <td class="formValue">
                        <textarea id="UseSay" name="UseSay" class="form-control input-sm" style="height: 60px;" autocomplete="off" ></textarea>
                    </td>
                 
                </tr>
                <tr>
                    <th class="formTitle">备注</th>
                    <td class="formValue" >
                        <textarea id="BZ" name="BZ" class="form-control input-sm" style="height: 60px;" autocomplete="off" ></textarea>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</div>
<script>
    $(function () {
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;

            form.render();

        });
    })
    function submitForm() {
        $("#form1").validate({
            rules: {
                StoreName: "required"
            }
        });

        if ($('#form1').valid()) {
            $.loading(true, "正在提交数据");
            window.setTimeout(function () {
                $.ajax({
                    url: "/StoreInfo/AddStore/",
                    data: $('#form1').serialize(),
                    type: "post",
                    dataType: "json",
                    success: function (data) {
                        $.loading(false);

                        if (data.errorMsg) {
                            layer.msg(data.errorMsg, { icon: 2 });
                        }
                        else {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            $.currentWindow().$("#list1").trigger("reloadGrid");
                            var msgs = (data.okMsg);
                            top.layer.msg(msgs, { icon: 1 });
                            parent.layer.close(index);
                        }

                    },
                    error: function (xhr, type, errorThrown) {
                        $.loading(false);;
                        if (type === 'timeout') {
                            layer.msg('连接超时，请稍后重试！', { icon: 2 });
                        } else if (type === 'error') {
                            layer.msg('连接异常，请稍后重试！', { icon: 2 });
                        }

                    },
                    complete: function () {
                        $.loading(false);
                    }
                });

            }, 500);
        }
    }
</script>



